// pages/volua/volua.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */



  data: {

    dangx:'',
    HISTORY_POINTS: '',
    flag: true, //设置节流

  },




  //点击拿数据
  xiang_q(e) {

 

    console.log(e.currentTarget.dataset.item);

    let that = this

    if (that.data.flag) {


      console.log(111);
      that.data.flag = false




      this.setData({
        dangx: e.currentTarget.dataset.item
      })

      this.receive_lin()



      setTimeout(() => {
        that.data.flag = true
      }, 2000)
    }
  },




  receive_lin() {

    wx.request({
      url: app.globalData.interface+'/shangluoTicket/API_5913_WalkingUserExchange',
      method: 'POST',
      data: {

        WALKING_ID: this.data.WALKING_ID,
        PRIZE_ID: this.data.dangx.PRIZE_ID,
        OPEN_ID: this.data.OPEN_ID, //用户OPEN_ID
        session_key: this.data.session_key,
        OPEN_UUID: this.data.jiami,
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log(res);
        wx.showModal({
          title: '温馨提示',
          content: res.data.data,
          success: function (res) {
            if (res.confirm) { //这里是点击了确定以后
              console.log('用户点击确定')
              wx.navigateBack({
                delta: 1,
              })
            } else { //这里是点击了取消以后
              console.log('用户点击取消')
              wx.navigateBack({
                delta: 1,
              })
            }
          }
        })
      }
    })
  },




























  wugandenglu() {
    wx.request({
      url: app.globalData.interface+'/shangluoTicket/API_5911_WalkingUserExchangeList',
      method: 'POST',
      data: {
        OPEN_ID: this.data.OPEN_ID, //用户OPEN_ID
        session_key: this.data.session_key,
        OPEN_UUID: this.data.jiami,

      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        console.log('---==', res);


        if (res.data.result == 'error') {
          wx.showModal({
            title: '温馨提示',
            content: res.data.data,
            success: function (res) {
              if (res.confirm) { //这里是点击了确定以后

              } else { //这里是点击了取消以后
                console.log('用户点击取消')
              }
            }
          })
        } else {
  

          this.setData({
            jiangsj: res.data.WalkingGoods,
            WALKING_ID: res.data.WalkingUser.WALKING_ID,

          })
        }
      }
    })
  },












  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {

    console.log(e.data);


    this.setData({
      HISTORY_POINTS: e.data,
      jiami: app.globalData.jiami,
      OPEN_ID: app.globalData.openid,
      session_key: app.globalData.session_key,
      phone: app.globalData.phone,

    })






  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {


    this.wugandenglu()
    // this.receive_lin()

    // const pages = getCurrentPages()
    // console.log(pages);

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})